package com.lingz.manager.modules.wuxue.controller;

import com.lingz.manager.base.DevplatBaseController;
import com.lingz.manager.common.utils.ResultUtil;
import com.lingz.manager.common.vo.Result;
import com.lingz.manager.modules.wuxue.entity.DeviceInfo;
import com.lingz.manager.modules.wuxue.entity.vo.DeviceAllInfo;
import com.lingz.manager.modules.wuxue.service.DeviceInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@RestController
@Api(description = "武穴设备元信息管理接口")
@RequestMapping("/wuxue/device")
@Transactional
public class DeviceInfoController {

    @Autowired
    DeviceInfoService deviceInfoService;

    @GetMapping("/deviceQuantityStatistics")
    @ApiOperation("设备统计")
    public Result<List> deviceQuantityStatistics(){
        return new ResultUtil<List>().setData(deviceInfoService.deviceQuantityStatistics());
    }

    @GetMapping("/deviceStatus")
    @ApiOperation("设备状态")
    public Result<List> deviceStatus(){
        return new ResultUtil<List>().setData(deviceInfoService.deviceStatus());
    }


    @GetMapping("/findDeviceInfoById")
    @ApiOperation("根据id获取设备")
    public Result<DeviceInfo> findDeviceInfoById(String id){
        return new ResultUtil<DeviceInfo>().setData(deviceInfoService.findDeviceInfoById(id));
    }

    @GetMapping("/findDeviceInfoByType")
    @ApiOperation("获取对应类型的设备")
    public Result<List<DeviceInfo>> findDeviceInfoByType(String deviceType){
        return new ResultUtil<List<DeviceInfo>>().setData(deviceInfoService.findDeviceInfoByType(deviceType));
    }

    @GetMapping("/findDeviceInfoGroupByPosition")
    @ApiOperation("获取对应位置的设备")
    public Result<ArrayList<ArrayList<DeviceInfo>>> findDeviceInfoGroupByPosition(){
        return new ResultUtil<ArrayList<ArrayList<DeviceInfo>>>().setData(deviceInfoService.findDeviceInfoGroupByPosition());
    }

    @GetMapping(value = "/findDeviceAllInfo")
    @ApiOperation(value = "获取设备的所有信息")
    public Result<List<DeviceAllInfo>> findDeviceAllInfo(){
        return new ResultUtil<List<DeviceAllInfo>>().setData(deviceInfoService.findDeviceAllInfo());
    }


    @GetMapping(value = "/findDeviceInfoList")
    @ApiOperation(value = "不分页查询设备信息")
    public Result<List<DeviceInfo>> findDeviceInfoList(DeviceInfo deviceInfo){
        return new ResultUtil<List<DeviceInfo>>().setData(deviceInfoService.findListDeviceInfo(deviceInfo));
    }

    @PostMapping("/insertDeviceInfo")
    @ApiOperation(value = "添加设备信息")
    public Result<String> insertDeviceInfo(@RequestBody DeviceInfo deviceInfo){
        return new ResultUtil<String>().setData(deviceInfoService.addDeviceInfo(deviceInfo));
    }

    @PostMapping("/editDeviceInfo")
    @ApiOperation(value = "修改设备信息")
    public Result<String> eidtDeviceInfo(@RequestBody DeviceInfo deviceInfo){
        return new ResultUtil<String>().setData(deviceInfoService.editDeviceInfo(deviceInfo));
    }

    @DeleteMapping("/deleteDeviceInfo")
    @ApiOperation(value = "删除设备信息")
    public Result<String> deleteDeviceInfo(String [] ids){
        return new ResultUtil<String>().setData(deviceInfoService.deleteDeviceInfo(ids));
    }

}
